package com.saihai.jiankang.ufXxzx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufXxzx.domain.UfXxzx;
import com.saihai.jiankang.ufXxzx.service.IUfXxzxService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 消息管理Controller
 * 
 * @author ruoyi
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/jiankang/ufXxzx")
public class UfXxzxController extends BaseController
{
    @Autowired
    private IUfXxzxService ufXxzxService;

    /**
     * 查询消息管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UfXxzx ufXxzx)
    {
        startPage();
        List<UfXxzx> list = ufXxzxService.selectUfXxzxList(ufXxzx);
        return getDataTable(list);
    }

    /**
     * 查询消息数量
     */
    @GetMapping("/selectMessageNum")
    public AjaxResult selectMessageNum(UfXxzx ufXxzx)
    {
        UfXxzx ufXxzx1 = ufXxzxService.selectMessageNum(ufXxzx);
        return AjaxResult.success(ufXxzx1.getId());
    }

    /**
     * 导出消息管理列表
     */
    @Log(title = "消息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfXxzx ufXxzx)
    {
        List<UfXxzx> list = ufXxzxService.selectUfXxzxList(ufXxzx);
        ExcelUtil<UfXxzx> util = new ExcelUtil<UfXxzx>(UfXxzx.class);
        util.exportExcel(response, list, "消息管理数据");
    }

    /**
     * 获取消息管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufXxzxService.selectUfXxzxById(id));
    }

    /**
     * 新增消息管理
     */
    @Log(title = "消息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfXxzx ufXxzx)
    {
        return toAjax(ufXxzxService.insertUfXxzx(ufXxzx));
    }

    /**
     * 修改消息管理
     */
    @Log(title = "消息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfXxzx ufXxzx)
    {
        return toAjax(ufXxzxService.updateUfXxzx(ufXxzx));
    }

    /**
     * 已读消息管理
     */
    @Log(title = "已读消息管理", businessType = BusinessType.UPDATE)
    @PutMapping("/readMessageNum/{ids}")
    public AjaxResult readMessageNum(@PathVariable Long[] ids)
    {
        return toAjax(ufXxzxService.readMessageNum(ids));
    }

    /**
     * 全部已读
     */
    @Log(title = "全部已读", businessType = BusinessType.UPDATE)
    @PutMapping("/allreadMessageNum/{id}")
    public AjaxResult allreadMessageNum(@PathVariable Long id)
    {
        return toAjax(ufXxzxService.allreadMessageNum(id));
    }

    /**
     * 删除消息管理
     */
    @Log(title = "消息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufXxzxService.deleteUfXxzxByIds(ids));
    }
}
